liwe.fx.slowfade = {};

liwe.fx.slowfade.base_opacity = 30;

liwe.fx.slowfade._int_slow_clear_timer = function ( e )
{
	if ( ! e.fx_slow_opacity ) e.fx_slow_opacity = def_opacity;
	if ( e.fx_slow_timer ) clearInterval ( e.fx_slow_timer );

	e.fx_slow_timer = 0;
};

liwe.fx.slowfade._int_slow_gradual = function ( e )
{
	e.fx_slow_opacity = liwe.fx.set_opacity ( e, e.fx_slow_opacity + e.fx_slow_delta );

	if ( e.fx_slow_opacity <= liwe.fx.slowfade.base_opacity || e.fx_slow_opacity >= 100 ) liwe.fx.slowfade._int_slow_clear_timer ( e );
};

liwe.fx.slowfade._in = function ( e )
{
	if ( ! e.fx_slow_opacity ) 
		e.fx_slow_opacity = liwe.fx.slowfade.base_opacity;
	else
		if ( e.fx_slow_opacity < liwe.fx.slowfade.base_opacity ) e.fx_slow_opacity = liwe.fx.slowfade.base_opacity;

	liwe.fx.slowfade._int_slow_clear_timer ( e );

	e.fx_slow_delta	  = 10;
	e.fx_slow_timer   = setInterval ( function () { liwe.fx.slowfade._int_slow_gradual ( e ); }, 50 );
};

liwe.fx.slowfade._out = function ( e )
{
	if ( ! e.fx_slow_opacity ) 
		e.fx_slow_opacity = 100;
	else
		if ( e.fx_slow_opacity > 100 ) e.fx_slow_opacity = 100;

	liwe.fx.slowfade._int_slow_clear_timer ( e );

	e.fx_slow_delta	  = -10;
	e.fx_slow_timer   = setInterval ( function () { liwe.fx.slowfade._int_slow_gradual ( e ); },  50 );
};

liwe.fx.slowfade.install = function ( e )
{
	e.onmouseover = function () { liwe.fx.slowfade._in  ( e ); };
	e.onmouseout  = function () { liwe.fx.slowfade._out ( e ); };
	e.fx_slow_opacity = liwe.fx.set_opacity ( e, liwe.fx.slowfade.base_opacity );
};
